/// @tags:
#include <cstdio>
#include <iostream>

using namespace std;

namespace BlueQuantum {

int n, T;

inline int main() {
  cin >> T;
  while (T--) {
    cin >> n;
    int ans = 0;
    for (int i = 1, a; i <= n; ++i) cin >> a, ans += a;
    cout << ans << '\n';
    for (int i = 1; i <= n; ++i) cout << "1 ";
    cout << '\n';
  }
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("External.in", "r", stdin);
  freopen("External.out", "w", stdout);
#endif
#endif

  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}